package com.lupan.guice.bindings.providerBindings;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.name.Names;
import com.lupan.guice.bindings.DatabaseTransactionLog;
import com.lupan.guice.bindings.TransactionLog;
import com.lupan.guice.bindings.providesMethods.BillingService4;
import com.lupan.guice.bindings.providesMethods.ProvidesMethodModule;

/**
 * 说明:
 *
 * @author lupan
 * @version 2016/9/27 0027 下午 9:56
 */
public class Main {
    public static void main(String[] args) {
        Injector injector = Guice.createInjector(new AbstractModule() {
            @Override
            protected void configure() {
                bind(String.class).annotatedWith(Names.named("jdbcUrl")).toInstance("jdbc:sqlserver://10.101.37.195:1433;databaseName=bscati");
                bind(Integer.class).annotatedWith(Names.named("maxPoolSize")).toInstance(10);
                bind(TransactionLog.class).toProvider(DatabaseTransactionLogProvider.class);
            }
        });

        TransactionLog log = injector.getInstance(TransactionLog.class);

        System.out.println(((DatabaseTransactionLog) log).getJdbcUrl());
        System.out.println(((DatabaseTransactionLog)log).getMaxPoolSize());
    }
}
